package com.yunji.storage.pattern;

import com.yunji.storage.domain.StockDO;
import org.springframework.stereotype.Component;
import org.springframework.util.Assert;

import java.math.BigDecimal;

/**
 * @Project: yunji-coffee
 * @Package: com.yunji.storage.pattern
 * @Title: OperateInteract
 * <p>
 * History:
 * Date                     Version     Author          Summary
 * ============================================================
 * 2024-09-14 16:49:22      V1.0        HuaAo       新建类
 */
@Component
public class OperateInteract extends AbstractStorage {

    @Override
    protected void addStorage(StockDO stock) {
        BigDecimal actualQuantity = stock.get(OPERATE_NUMS);

        logs.info("【员工补货】增加库存:{}", actualQuantity);

        StockDO update = new StockDO();
        update.setBelongId(stock.getBelongId());
        update.setProductId(stock.getProductId());
        update.setFrozenStock(actualQuantity);
        update.setUsableStock(actualQuantity.negate());
        logs.info("【员工补货】库存数据:{}", update);
        Assert.isTrue(stockService.updateStock(update), "入库失败");
    }

    @Override
    protected void subtractStock(StockDO stock) {
        logs.info("【员工补货】{}", stock);
    }

    @Override
    protected void backStock(StockDO stock) {
        logs.info("【员工补货】返还库存:{}", stock);
    }

    @Override
    protected void createBackStock(StockDO stock) {
        logs.info("【补货库存处理】新增返还库存:{}", stock);
    }

    @Override
    public void updateTicket(Long businessId) {
        logs.info("【员工补货】");
    }

    @Override
    public void checkTicket(String businessCode) {
        logs.info("【员工补货】");
    }
}